***Well-being (only from 2004)***

*2004
use "${original}H04LB_R.dta", clear
rename *, lower

gen hhidpn = hhid+ pn

***Life satisfaction
rename jlb505c r7lifesat_c
label variable r7lifesat_c "r7lifesat_c: satisfied with life"
***Optimism
rename jlb506p r7optimism_c
label variable r7optimism_c "r7optimism_c: expect the best in uncertain times"
***Financial strain
rename jlb530e r7stress_e
label variable r7stress_e "r7stress_e: ongoing financial strain"

save H04LB_R_new.dta, replace


*2006
use "${original}H06LB_R.dta", clear
rename *, lower

gen hhidpn = hhid+ pn

***Life satisfaction
rename klb003c r8lifesat_c
label variable r8lifesat_c "r8lifesat_c: satisfied with life"
***Optimism
rename klb019h r8optimism_c
label variable r8optimism_c "r8optimism_c: expect the best in uncertain times"
***Financial strain
rename klb040e r8stress_e
label variable r8stress_e "r8stress_e: ongoing financial strain"
***Control over financial situation
rename klb026 r8contr_fin 
label variable r8contr_fin "r8contr_fin: control over financial situation"

save H06LB_R_new.dta, replace


*2008
use "${original}H08LB_R.dta", clear
rename *, lower

gen hhidpn = hhid+ pn

***Life satisfaction
rename llb003c r9lifesat_c
label variable r9lifesat_c "r9lifesat_c: satisfied with life"
***Optimism
rename llb019h r9optimism_c
label variable r9optimism_c "r9optimism_c: expect the best in uncertain times"
***Control over financial situation
rename llb026 r9contr_fin 
label variable r9contr_fin "r9contr_fin: control over financial situation"

save H08LB_R_new.dta, replace


*2010
use "${original}H10LB_R.dta", clear
rename *, lower

gen hhidpn = hhid+ pn

***Life satisfaction
rename mlb003c r10lifesat_c
label variable r10lifesat_c "r10lifesat_c: satisfied with life"
***Optimism
rename mlb019h r10optimism_c
label variable r10optimism_c "r10optimism_c: expect the best in uncertain times"
***Financial strain
rename mlb040a_e r10stress_e
label variable r10stress_e "r10stress_e: ongoing financial strain"
***Control over financial situation
rename mlb026 r10contr_fin 
label variable r10contr_fin "r10contr_fin: control over financial situation"

save H10LB_R_new.dta, replace


*2012
use "${original}H12LB_R.dta", clear
rename *, lower

gen hhidpn = hhid+ pn

***Life satisfaction
rename nlb003c r11lifesat_c
label variable r11lifesat_c "r11lifesat_c: satisfied with life"
***Optimism
rename nlb019h r11optimism_c
label variable r11optimism_c "r11optimism_c: expect the best in uncertain times"
***Financial strain
rename nlb040a_e r11stress_e
label variable r11stress_e "r11stress_e: ongoing financial strain"
***Control over financial situation
rename nlb026 r11contr_fin 
label variable r11contr_fin "r11contr_fin: control over financial situation"

save H12LB_R_new.dta, replace


*2014
use "${original}H14LB_R.dta", clear
rename *, lower

gen hhidpn = hhid+ pn

***Life satisfaction
rename olb002c r12lifesat_c
label variable r12lifesat_c "r12lifesat_c: satisfied with life"
***Optimism
rename olb018c r12optimism_c
label variable r12optimism_c "r12optimism_c: expect the best in uncertain times"
***Financial strain
rename olb035a_5 r12stress_e
label variable r12stress_e "r12stress_e: ongoing financial strain"
***Control over financial situation
rename olb025 r12contr_fin 
label variable r12contr_fin "r12contr_fin: control over financial situation"

save H14LB_R_new.dta, replace


*Merge
use H04LB_R_new.dta, clear
keep hhid pn r7lifesat_c r7optimism_c r7stress_e
merge 1:1 hhid pn using H06LB_R_new.dta, keepusing(r8lifesat_c r8optimism_c r8contr_fin r8stress_e)
drop _merge 
merge 1:1 hhid pn using H08LB_R_new.dta, keepusing(r9lifesat_c r9optimism_c r9contr_fin)
drop _merge
merge 1:1 hhid pn using H10LB_R_new.dta, keepusing(r10lifesat_c r10optimism_c r10contr_fin r10stress_e)
drop _merge
merge 1:1 hhid pn using H12LB_R_new.dta, keepusing(r11lifesat_c r11optimism_c r11contr_fin r11stress_e)
drop _merge
merge 1:1 hhid pn using H14LB_R_new.dta, keepusing(r12lifesat_c r12optimism_c r12contr_fin r12stress_e)
drop _merge

save wellbeing.dta, replace

*Erase temporary datasets
foreach n in 04 06 08 10 12 14 {
erase H`n'LB_r_new.dta
}